package com.company.common.function.mybatis_plus.config;

import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
//接口动态实现生成实体类对象，实现类对象默认找不到，需要通过@MapperScan扫描
@MapperScan("com.example.mybatis_plus.mapper")
public class MpConfig {
    //@Bean 通常配置在启动类 由于开发习惯 将@Bean统一配置在config中 然后将启动类中的扫描移入

    /**
     * 乐观锁插件
     */
    @Bean
    public OptimisticLockerInterceptor optimisticLockerInterceptor() {
        return new OptimisticLockerInterceptor();
    }

    /**
     * 分页插件
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }
}
